"""author: wangxin
   data: 2021/12/26
   project: wangxin
"""

# 基类：实现往Linux系统里添加用户
# 子类A：能够查看、修改uid和gid，shell等信息
# 子类B:1、能删除用户 2、能删除组
# 子类C(A,B)：1、可以单独新建组 2、可以将某个用户的gid修改为新建组的uid 3、加入异常机制，异常的名字需要自己定义

import os


class Base():
    def addcreat(self, name):
        os.system(f'useradd {name}')


class A(Base):
    def cheak(self, name):
        os.system(f'id {name}')

    def uidmod(self, name, uid):
        os.system(f'usermod -u {uid} {name}')

    def gidmod(self, name, gid):
        os.system(f'usermod -g {gid} {name}')

    def shellmod(self, name, shell):
        os.system(f'usermod -s {shell} {name}')




class B(Base):
    def userdel(self, name):
        os.system(f'userdel {name}')

    def groupdel(self, gname):
        os.system(f'groupdel {gname}')


class C(A, B, Exception):
    def groupadd(self, gname):
        self.gname = gname
        os.system(f'groupadd {gname}')

    def usermod(self, name):
        os.system(f'usermod -g {self.gname} {name}')

    def __init__(self, error):
        self.error = error

    def __str__(self):
        return self.error

